package com.wsd.jing.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wsd.jing.validator.group.InsertGroup;
import com.wsd.jing.validator.group.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * All rights Reserved, Designed By www.tom.com
 *
 * @author tom
 * @version 1.0.0
 * @projectName: jing
 * @packageName: com.wsd.jing.entity
 * @className: BusinessLog
 * @description: 业务日志
 * @createDate 2022-11-14 07:02
 * @copyright 2022-11-14 07:02 www.tom.com Inc. All rights reserved.
 */
@Getter
@Setter
@ToString
@TableName("j_business_log")
@ApiModel(value = "BusinessLog对象", description = "业务日志表")
public class BusinessLog implements Serializable {

    private static final long serialVersionUID = 1L;

    @NotNull(message = "日志ID不能为空", groups = UpdateGroup.class)
    @Null(message = "日志ID为空", groups = InsertGroup.class)
    @ApiModelProperty("日志ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @NotBlank(message = "操作账号不能为空")
    @ApiModelProperty("操作账号")
    @TableField("account")
    private String account;

    @NotBlank(message = "模块不能为空")
    @ApiModelProperty("模块")
    @TableField("module")
    private String module;

    @NotBlank(message = "耗时不能为空")
    @ApiModelProperty("耗时")
    @TableField("time")
    private Long time;

    @NotBlank(message = "请求类型不能为空")
    @ApiModelProperty("请求类型")
    @TableField("method")
    private String method;

    @NotBlank(message = "请求参数不能为空")
    @ApiModelProperty("请求参数")
    @TableField("params")
    private String params;

    @NotBlank(message = "请求uri不能为空")
    @ApiModelProperty("请求uri")
    @TableField("uri")
    private String uri;

    @ApiModelProperty("操作者IP")
    @TableField("ip")
    private String ip;

    @ApiModelProperty("操作地点")
    @TableField("location")
    private String location;

    @NotBlank(message = "操作结果不能为空")
    @ApiModelProperty("操作结果")
    @TableField("result")
    private String result;

    @NotNull(message = "创建时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty("创建时间")
    @TableField("create_time")
    private LocalDateTime createTime;
}
